# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=tar
pkgver=1.32
pkgrel=1
pkgdesc="Utility used to store, backup, and transport files"
arch=('i686' 'x86_64')
url="https://www.gnu.org/software/tar/tar.html"
license=('GPL3')
groups=('compression')
depends=('msys2-runtime' 'libiconv' 'libintl' 'sh')
makedepends=('libiconv-devel' 'gettext-devel')
options=('!emptydirs')
install=tar.install
source=(https://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.xz{,.sig}
        1.29-mode-binary.patch
        tar-1.31-msys2.patch)
sha256sums=('d0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8'
            'SKIP'
            'e96dd022ce1d8749c766820ed1465d5f56f76a2c5e7eaeada473e9d652f5a3b1'
            '72ebad71a176bd3ab32248c4a1d1ada1bb3c26cf359c8a1cb501a9288b19c479')
validpgpkeys=('325F650C4C2B6AD58807327A3602B07F55D0C732') # Sergey Poznyakoff

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}

  patch -p1 -i ${srcdir}/1.29-mode-binary.patch
  patch -p1 -i ${srcdir}/tar-1.31-msys2.patch

  autoreconf -fi
}

build() {
  cd ${srcdir}/${pkgname}-${pkgver}
  ./configure \
    --build=${CHOST} \
    --prefix=/usr \
    --sbindir=/usr/bin \
    --libexecdir=/usr/lib/tar \
    --enable-backup-scripts
  make
}

check() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make check || true
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make DESTDIR=${pkgdir} install
}
